<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_CityMapper {
	protected $_db_table;

	public function __construct() {
		$this->_db_table = new Api_Model_DbTable_City();
	}

	public function getAllCity() {
		$select = $this->_db_table->select()->from('cities', array('*'));

		$result = $this->_db_table->fetchAll($select);


		if(count($result) == 0) {
			throw new Exception(json_encode(array('meta' => 'Not found')),404);
		} else {
			foreach ($result as $row) {

				$city[] = array('city' => array('city_id' => utf8_encode($row->city_id),
                                                    'name' => utf8_encode($row->name)));
			}
			return $city;
		}
	}



}